/*
 * Copyright (C) 2017 Pingan, Inc. All Rights Reserved.
 */

package com.pingan.haofang.searchcloud.web.index.vo;

import com.pingan.haofang.searchcloud.common.auth.AuthDataType;
import com.pingan.haofang.searchcloud.common.auth.ValidDataAuth;
import com.pingan.haofang.searchcloud.common.constants.Constants;
import com.pingan.haofang.searchcloud.index.constants.IndexDataSourceType;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotBlank;

import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;

/**
 * 导入任务主视图
 * 注:这里请求和响应是对称的，用一个对象来表示
 *
 * @author zhangbi617
 * @date 03/05/2017
 */
@ApiModel(description = "导入任务主视图")
public class IndexDatasourceVO {


    /**
     * ID
     */
    @ApiModelProperty(value = "数据源ID", example = "10")
    private Long id;

    /**
     * 数据源名称
     */
    @ApiModelProperty(value = "数据源名称", example = "HdmpHouse")
    @NotBlank
    @Length(min = 2, max = 64)
    @Pattern(regexp = Constants.NAME_PATTERN, message = "common.name.pattern.error")
    private String name;

    /**
     * 索引ID
     */
    @NotNull
    @ApiModelProperty(value = "索引ID", example = "1")
    @ValidDataAuth(dataType = AuthDataType.INDEX_ID)
    private Long indexId;


    /**
     * 全量导入方式
     *
     * @see IndexDataSourceType
     */
    @ApiModelProperty(value = "全量导入方式,0-JSON_RPC，1-消息队列(暂不支持)，2-数据库SQL(暂不支持)", allowableValues = "0")
    @NotNull
    private Integer fullDatasourceType;

    /**
     * 增量导入方式
     *
     * @see IndexDataSourceType
     */
    @ApiModelProperty(value = "增量导入方式,-1-不支持，0-JSON_RPC，1-消息队列(暂不支持)，2-数据库SQL(暂不支持)", allowableValues = "-1,0")
    @NotNull
    private Integer incDatasourceType;

    /**
     * 全量导入设置,当fullImportType取值为0时需要传该字段
     */
    @ApiModelProperty(value = "全量导入设置,当fullDatasourceType取值为0时需要传该字段")
    @NotNull
    @Valid
    private FullRpcIndexDataSourceVO fullDatasourceRpc;

    /**
     * 增量导入设置,当incImportType取值为0时需要传该字段
     */
    @ApiModelProperty(value = "增量导入设置,当incDatasourceType取值为0时需要传该字段")
    @Valid
    private IncCallbackRpcIndexDataSourceVO incDatasourceRpc;

    @ApiModelProperty(value = "创建人")
    private String createByName;


    public Integer getFullDatasourceType() {
        return fullDatasourceType;
    }

    public void setFullDatasourceType(Integer fullDatasourceType) {
        this.fullDatasourceType = fullDatasourceType;
    }

    public Integer getIncDatasourceType() {
        return incDatasourceType;
    }

    public void setIncDatasourceType(Integer incDatasourceType) {
        this.incDatasourceType = incDatasourceType;
    }

    public FullRpcIndexDataSourceVO getFullDatasourceRpc() {
        return fullDatasourceRpc;
    }

    public void setFullDatasourceRpc(FullRpcIndexDataSourceVO fullDatasourceRpc) {
        this.fullDatasourceRpc = fullDatasourceRpc;
    }

    public IncCallbackRpcIndexDataSourceVO getIncDatasourceRpc() {
        return incDatasourceRpc;
    }

    public void setIncDatasourceRpc(IncCallbackRpcIndexDataSourceVO incDatasourceRpc) {
        this.incDatasourceRpc = incDatasourceRpc;
    }

    /**
     * @return the id
     */
    public Long getId() {
        return id;
    }

    /**
     * @param id the id to set
     */
    public void setId(Long id) {
        this.id = id;
    }

    /**
     * @return the name
     */
    public String getName() {
        return name;
    }

    /**
     * @param name the name to set
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * @return the indexId
     */
    public Long getIndexId() {
        return indexId;
    }

    /**
     * @param indexId the indexId to set
     */
    public void setIndexId(Long indexId) {
        this.indexId = indexId;
    }


    public String getCreateByName() {
        return createByName;
    }

    public void setCreateByName(String createByName) {
        this.createByName = createByName;
    }

    @Override
    public String toString() {
        return "IndexDatasourceVO{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", indexId=" + indexId +
                ", fullDatasourceType=" + fullDatasourceType +
                ", incDatasourceType=" + incDatasourceType +
                ", fullDatasourceRpc=" + fullDatasourceRpc +
                ", incDatasourceRpc=" + incDatasourceRpc +
                ", createByName='" + createByName + '\'' +
                '}';
    }
}
